package com.xingkeduo.business.user.controller;

import com.xingkeduo.business.transformation.json.CraftsmanJTO;
import com.xingkeduo.business.transformation.json.CraftsmanJobJTO;
import com.xingkeduo.business.transformation.json.CraftsmanSocialJTO;
import com.xingkeduo.business.user.domain.ManageInfoDomain;
import com.xingkeduo.pojo.query.CraftsmanJobQO;
import com.xingkeduo.pojo.query.CraftsmanQO;
import com.xingkeduo.pojo.query.CraftsmanSocialQO;
import com.xingkeduo.pojo.table.CraftsmanTO;
import com.xingkeduo.util.pojo.base.BaseController;
import com.xingkeduo.util.pojo.domain.Page;
import com.xingkeduo.util.pojo.domain.PageJTO;
import com.xingkeduo.util.tool.ReturnUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 一线员工 列表
 * 
 * @author 高杰
 * @time 2019年1月7日 下午6:57:47
 * @description
 */
//@CrossOrigin
@RestController
@RequestMapping("/craftsman/list")
public class CraftsmanListController extends BaseController {
	@Autowired
	private ManageInfoDomain manageInfoDomain;

	/**
	 * 一线员工列表接口
	 * 
	 * @author 高杰
	 * @time 2019年1月7日 下午6:57:57
	 * @param url
	 * @return
	 */
	@GetMapping(value = "/{url:.+}")
	public String doGet(@PathVariable String url,int page,int limit) {
		returnUtil = new ReturnUtil();
		try {
			CraftsmanQO craftsmanQuery = CraftsmanJTO.createQueryForList(url);
			CraftsmanJobQO craftsmanJobQuery = CraftsmanJobJTO.createQueryForList(url);
			CraftsmanSocialQO craftsmanSocialQuery = CraftsmanSocialJTO.createQueryForList(url);
			Page<CraftsmanTO> pageDO = new Page<CraftsmanTO>(page, limit);

			return returnUtil.getSuccess(PageJTO.toJson(pageDO,CraftsmanJTO.toJson(manageInfoDomain.getCraftsmans(craftsmanQuery, craftsmanJobQuery, craftsmanSocialQuery,pageDO))));
		} catch (Throwable t) {
			return dealException(t, returnUtil);
		}
	}

}
